package com.liu.oss.controller;

import com.liu.commonutils.ReturnResult;
import com.liu.oss.service.OssService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/edu_oss/fileoss")
@Api(description = "阿里云文件上传")
@CrossOrigin
public class OssController {


    @Autowired
    private OssService ossService;

    @ApiOperation("文件上传")
    @PostMapping("/upload")
    public ReturnResult uploadFile(MultipartFile file){

        // 获取要上传的文件
        String url = ossService.uploadFileAvatar(file);


        return ReturnResult.ok().data("url",url);
    }
}
